#include <stdio.h>

int main(int argc, char *argv[]) {

    int n = 0;
    scanf("%d", &n);

    for (size_t i = 0; i < n; i++)
    {
        int nums[6] = {0};
        for (size_t i = 0; i < 6; i++)
        {
            scanf("%d", &nums[i]);
        }

        int h = nums[0] + nums[3];
        int m = nums[1] + nums[4];
        int s = nums[2] + nums[5];

        while (s>=60)
        {
            m += 1;
            s -= 60;
        }
        
        while (m>=60)
        {
            h += 1;
            m -= 60;
        }

        

        printf("%d %d %d\n", h, m, s);
    }
    

    return 0;
}